
/**
 * mockjs 文档 
 * http://mockjs.com/examples.html#String
 * 
 * 数据占位符定义 Random
 * http://mockjs.com/examples.html#Basic
 */
import Mock from "mockjs"
const { Random } = Mock

class result {
    constructor(data) {
        this.resultCode = 200
        this.success = 'mock 成功'
        this.data = data
    }
}

/**
 * 闭包结合Object创建命名空间
 * 注意Vue 页面使用方式： 
 *   
    import mockFun from "@/mock/fun"
    const {mockList,...} = mockFun.ClaimStatementQueryDealer.mockListWrap() // 涉及闭包 所以需要先调用外层函数一次 
 */
const muduleName = 'ClaimStatementQueryDealer'
const NameSpace = NameSpace || {};
NameSpace[muduleName] = (function () {
    //待返回的公有对象  
    var self = {};
    //私有变量或方法   
    // var name = 'world';
    //公有方法或变量 (通过 mockFunWrap方法 导出所有mock方法)  
    self.mockFunWrap = function () {
        return {
            mockList // mockList:mockList 简写
            // ... 添加需要导出的mock方法
         } 
    };
    //返回的公有对象   
    return self;
}());

/**
 * 实际mock方法合集 >>>>>>>>>>>>>>
 */


/**
 * mock 索赔结算单查询列表
 * @returns {Object} Promise
 */
const mockList = () => {
    try {
        const id = Random.id();
        const name = Random.cname();
        const date = Random.datetime();
        const mockData = Mock.mock({
            'rows|5-10': [{
                addAmount: null,
                appId: `appid${id}`,
                applyDate: null,
                applyDateStr: null,
                assessAmount: null,
                assessIds: null,
                assessList: null,
                beginIssueDate: null,
                beginSettleDate: null,
                carType: null,
                carTypeStr: null,
                claimAmount: null,
                claimCount: null,
                claimIds: null,
                claimList: null,
                createdAt: null,
                createdBy: null,
                currentPage: 0,
                dealerCode: "R110101",
                dealerId: null,
                dealerName: "北京北方伟业汽车销售服务有限公司",
                endIssueDate: null,
                endSettleDate: null,
                firstMaintenance: 0,
                isDeleted: null,
                issueDate: null,
                labourAmount: '叶子板维修',
                normalClaim: 0,
                orgId: null,
                ownerCode: null,
                ownerParCode: null,
                pageSize: 0,
                partAmount: null,
                partClaim: 0,
                pdi: 0,
                preClaim: 0,
                recordVersion: null,
                serviceAction: 0,
                settleAmount: 76,
                settleDate: null,
                settleId: null,
                settleNo: "ST202104200001",
                settleStatus: 50011001,
                settleStatusStr: null,
                statusForFlag: null,
                technologicalUpgrade: 0,
                updatedAt: null,
                updatedBy: null
            }]
        })
        /**
         * 返回一个Promise对象
         *     resolve 对应 .then((res)=>{...})
         *     reject  对应 .catch((err)=>{...})
         */
        return Promise.resolve(new result(mockData.rows))
    } catch (err) {
        console.log(err)
    }
}

/**
 * 实际mock方法合集 <<<<<<<<<<<<<<<<<<
 */


export default NameSpace;
